<?php
declare(strict_types=1);

use Hyperf\Contract\LengthAwarePaginatorInterface;

if (!function_exists('is_production')) {
    function is_production(): bool
    {
        return env('APP_ENV') === 'production';
    }
}

if (!function_exists('map_paginator')) {
    function map_paginator(\Hyperf\Contract\LengthAwarePaginatorInterface $paginator, callable $callback): LengthAwarePaginatorInterface
    {
        $data = $paginator->map($callback);
        return $paginator->setCollection($data);
    }
}

if (!function_exists('event')) {
    function event(mixed $event)
    {
        $dispatcher = \Hyperf\Utils\ApplicationContext::getContainer()->get(\Psr\EventDispatcher\EventDispatcherInterface::class);

        return $dispatcher->dispatch($event);
    }
}